<?php

namespace common\enums;

use MyCLabs\Enum\Enum;

/**
 * 响应状态码枚举
 * @method static LOGIN_FAILED()
 * @method static THE_ENCRYPTED_OBJECT_CANNOT_BE_EMPTY()
 * @method static LOGIN_ERRORS_ARE_TOO_FREQUENT()
 * @method static USER_DOES_NOT_EXIST()
 * @method static PASSWORD_ERROR()
 */
class ResponseCode extends Enum
{
    const LOGIN_FAILED = [50101, '登录失败'];
    const LOGIN_ERRORS_ARE_TOO_FREQUENT = [50102, '登录错误太频繁，请稍后在试'];
    const USER_DOES_NOT_EXIST = [50103, '用户不存在，请检查用户名是否填写错误'];
    const PASSWORD_ERROR = [50104, '密码错误'];

    const THE_ENCRYPTED_OBJECT_CANNOT_BE_EMPTY = [60101, '加密对象不能为空'];

    private int $code;
    private string $message;

    public function __construct($value)
    {
        list($this->code, $this->message) = $value;
        parent::__construct($value);
    }


    /**
     * @return int
     */
    public function getCode(): int
    {
        return $this->code;
    }

    /**
     * @return string
     */
    public function getMessage(): string
    {
        return $this->message;
    }
}
